<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>

<%@ include file="../layout/header.jsp"%>
<div class="container" style="margin-top:50px;">
	<div class="row">
		<h1>新增角色</h1>	
		<form action="${ctx}/role.do?type=add" method="post" onsubmit="return validate();">
		  <div class="form-group">
		    <label for="roleName">角色名称<span style="color:red;">${msg}</span></label>
		    <input type="text" class="form-control" id="roleName" name="roleName" value="${role.roleName}" placeholder="请输入角色名称">
		  </div>
		  <div class="form-group">
		    <label for="description">角色描述</label>
		    <input type="text" class="form-control" id="description" name="description" placeholder="角色描述">
		  </div>		  
		  <button type="submit" class="btn btn-default">确定</button>
		  <a type="button" class="btn btn-default" href="${ctx}/role.do?type=getAll">取消</a>
		</form>
 	</div>    	
 </div>
<%@ include file="../layout/footer.jsp"%>

<script type="text/javascript">
	//前台验证
	function validate(){
		var flag = true;
		var roleName = $("#roleName").val().trim();
		var description = $("#description").val().trim();
		if(roleName == "" || roleName.length == 0){
			alert("角色名称不能为空！");
			flag = false;
		}
		if(description == "" || description.length == 0){
			alert("角色描述不能为空！");
			flag = false;
		}		
		return flag;
	}
</script>  
    
    
    
    